FROM ubuntu:16.04
MAINTAINER "WuHongLiang@Paint"

ENV LC_ALL C.UTF-8
ENV DEBIAN_FRONTEND noninteractive
ENV TZ=Asia/Shanghai
#set localtime
RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime \
    && echo $TZ > /etc/timezone

COPY FileRewrite/etc/apt/sources.list /etc/apt/sources.list

WORKDIR /usr/src/
RUN apt-get update && \
    apt-get -y install libssl-dev \
                       libpcre3-dev \
                       zlib1g-dev \
                       libgeoip-dev \
                       libxslt1-dev \
                       libgd2-dev \
                       build-essential \
                       libc6 \
                       libexpat1 \
                       libgd2-xpm-dev \
                       libgeoip1 \
                       libgeoip-dev \
                       libpam0g \
                       libssl1.0.0 \
                       libxml2 \
                       libxslt1.1 \
                       zlib1g \
                       openssl \
                       libgd2-xpm-dev \
                       libgeoip-dev \
                       libxslt1-dev \
                       libpcre++-dev \
                       libperl-dev \
                       wget \
                       curl



RUN curl -fSL http://nginx.org/download/nginx-1.18.0.tar.gz -o nginx-1.18.0.tar.gz \
    && curl -fSL https://github.com/cubicdaiya/ngx_dynamic_upstream/archive/v0.1.6.tar.gz -o ngx_dynamic_upstream-0.1.6.tar.gz \
    && curl -fSl https://codeload.github.com/openresty/headers-more-nginx-module/tar.gz/master -o headers-more-nginx-module-master.tar.gz \
    && tar -zxvf nginx-1.18.0.tar.gz \
    && tar -zxvf headers-more-nginx-module-master.tar.gz \
    && tar -zxvf ngx_dynamic_upstream-0.1.6.tar.gz

RUN cd nginx-1.18.0 \
   && ./configure \
        --user=www-data \
        --group=www-data \
        --conf-path=/etc/nginx/nginx.conf \
        --lock-path=/var/lock/nginx.lock \
        --pid-path=/run/nginx.pid \
        --with-http_ssl_module \
        --with-http_gzip_static_module \
        --with-http_gunzip_module \
        --with-http_auth_request_module \
        --with-http_image_filter_module \
        --with-http_addition_module \
        --with-http_dav_module \
        --with-http_realip_module \
        --with-http_ssl_module \
        --with-http_stub_status_module \
        --with-http_sub_module \
        --with-http_xslt_module \
        --with-file-aio \
        --with-pcre \
        --with-pcre-jit \
        --prefix=/etc/nginx \
        --with-debug \
        --http-log-path=/var/log/nginx/access.log \
        --error-log-path=/var/log/nginx/error.log \
        --sbin-path=/usr/sbin/nginx \
        --add-module=/usr/src/ngx_dynamic_upstream-0.1.6 \
        --add-module=/usr/src/headers-more-nginx-module-master \
    && make && make install

RUN rm -rf /usr/src && \
    apt-get clean all && \
    rm -rf /tmp/*

COPY FileRewrite/ /
WORKDIR /etc/nginx
EXPOSE 80 443

ENTRYPOINT ["/root/entrypoint.sh"]
CMD ["nginx"]